package com.ericsson.resourceplanner.web;

import java.util.List;
import java.util.Locale;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ericsson.resourceplanner.dao.entity.Report;
import com.ericsson.resourceplanner.service.ReportService;

@Controller
public class ReportController {
	
	private final static Logger logger = LoggerFactory.getLogger(ReportController.class);
	
	@Autowired
	private  ReportService reportService;

	
	public ReportService getReportService() {
		return reportService;
	}

	public void setReportService(ReportService reportService) {
		this.reportService = reportService;
	}

	 @RequestMapping(value = "/GetReport", method = RequestMethod.GET)
		public String home(Locale locale, Model model) {
			
			return "HomePage";
		}
	
	
	@RequestMapping(value ="/papulateReport", method = RequestMethod.GET)
	public @ResponseBody List<Report> getUtilizationReport(HttpServletRequest request){
	//	System.out.println("input month and year:"+mnth+":"+yr);
	// @RequestParam("month") String mnth ,@RequestParam("year") String yr	 
		
		String month = request.getParameter("month");
		String year = request.getParameter("year");
		System.out.println("month,year:"+month +":"+year);
		
		
	    return 	reportService.getUtilReport(month,year);
		
		
		
	}
	
	
}
